package wec_wallet.ebo.com.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import wec_wallet.ebo.com.R;
import wec_wallet.ebo.com.bean.WalletDateBean;

/**
 * Created by Administrator on 2018/3/28.
 */

public class WalletAdapter extends BaseAdapter {
    Context context;
    List<WalletDateBean> list;
    LayoutInflater inflater;

    public WalletAdapter(Context context, List<WalletDateBean> list) {
        this.context = context;
        this.list = list;
        this.inflater = LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int i) {
        return list.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }


    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        ViewHolder holder;
        if (view == null) {
            view = inflater.inflate(R.layout.activity_list_item_wallet, null);
            holder = new ViewHolder(view);
            view.setTag(holder);

        } else {
            holder = (ViewHolder) view.getTag();
        }
//        holder.imgItemWallet.setImageResource(R.drawable.ic_logout);
        holder.tvItemWalletCoin.setText(list.get(i).getNum() + " WEC");
        holder.tvItemWalletMoney.setText("≈" + list.get(i).getCny_price() + " " + "CNY");
        holder.tvItemWalletName.setText(list.get(i).getWallet_name());

        return view;
    }

    static class ViewHolder {
        @BindView(R.id.img_itemWallet)
        ImageView imgItemWallet;
        @BindView(R.id.tv_itemWallet_name)
        TextView tvItemWalletName;
        @BindView(R.id.tv_itemWallet_coin)
        TextView tvItemWalletCoin;
        @BindView(R.id.tv_itemWallet_money)
        TextView tvItemWalletMoney;

        ViewHolder(View view) {
            ButterKnife.bind(this, view);
        }
    }
}
